﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class shoucangjiluadd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null)
        {

        }
        else
        {
            Response.Write("<script>javascript:alert('对不起，请您先登陆！');history.back();</script>");
            Response.End();
        }
        if (!IsPostBack)
        {
            shoucangren.Text = Session["username"].ToString().Trim();
            // xingbie.Items.Add("male"); 
            // xingbie.Items.Add("female");
            // addxiala("kehuxinxi","bianhao","kehubianhao");
            gequID.Text = Request.QueryString["id"].ToString().Trim();
            string sql;
            sql = "select * from gequxinxi where id=" + Request.QueryString["id"].ToString().Trim();
            getdata(sql);
        }
    }
    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                bianhao.Text = result.Tables[0].Rows[0]["bianhao"].ToString().Trim();
                geming.Text = result.Tables[0].Rows[0]["geming"].ToString().Trim();
                leibie.Text = result.Tables[0].Rows[0]["leibie"].ToString().Trim();
                geshou.Text = result.Tables[0].Rows[0]["geshou"].ToString().Trim(); 
                //zuoci.Text = result.Tables[0].Rows[0]["zuoci"].ToString().Trim(); zuoqu.Text = result.Tables[0].Rows[0]["zuoqu"].ToString().Trim(); geci.Text = result.Tables[0].Rows[0]["geci"].ToString(); wenjian.Text = result.Tables[0].Rows[0]["wenjian"].ToString().Trim(); faburen.Text = result.Tables[0].Rows[0]["faburen"].ToString().Trim();

            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
        sql = "insert into shoucangjilu(gequID,bianhao,geming,leibie,geshou,shoucangren,beizhu) values('" + gequID.Text.ToString().Trim() + "','" + bianhao.Text.ToString().Trim() + "','" + geming.Text.ToString().Trim() + "','" + leibie.Text.ToString().Trim() + "','" + geshou.Text.ToString().Trim() + "','" + shoucangren.Text.ToString().Trim() + "','" + beizhu.Text.ToString().Trim() + "') ";
        int result;
        result = new Class1().hsgexucute(sql);
        if (result == 1)
        {
            Response.Write("<script>javascript:alert('添加成功');</script>");
        }
        else
        {
            Response.Write("<script>javascript:alert('系统错误，请检查数据库设置问题');</script>");
        }
    }
    //private void addxiala(string ntable, string nzd, string nxlk)
    //{
    //    string sql;
    //    sql = "select "+nzd+" from "+ntable+" order by id desc";
    //    DataSet result = new DataSet();
    //    result = new Class1().hsggetdata(sql);
    //    if (result != null)
    //    {
    //        if (result.Tables[0].Rows.Count > 0)
    //       {
    //            int i = 0;
    //            for (i = 0; i < result.Tables[0].Rows.Count; i++)
    //            {
    //                kehubianhao.Items.Add(result.Tables[0].Rows[i][0].ToString().Trim());
    //            }
    //        }
    //    }
    //}
}

